﻿using System.Windows;
using System.Windows.Controls;
using GSSoftSL.ViewModel.HocVienVM;
using GalaSoft.MvvmLight.Messaging;

namespace GSSoftSL.Views.HocVienView
{
    /// <summary>
    /// Description for HocVienHocPhiView.
    /// </summary>
    public partial class HocVienHocPhiView : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the HocVienHocPhiView class.
        /// </summary>
        public HocVienHocPhiView()
        {
            InitializeComponent();
        }

        private void DataGrid_LostFocus(object sender, RoutedEventArgs e)
        {
            DataGrid dg = sender as DataGrid;
            dg.SelectedIndex = -1;
        }

        private void DataGrid_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            DataGrid dg = sender as DataGrid;
            dg.SelectedIndex = -1;
        }

        private void DataGrid_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)
        {
            ((HocVienHocPhiViewModel)this.DataContext).CalculateBienLai();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Send<HocVienMainView.EnumContentState, HocVienMainViewModel>(HocVienMainView.EnumContentState.LopHocVien);
            Messenger.Default.Send(HocVienMainView.EnumContentState.LopHocVien);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}